package com.aids_malaria.ui.setting;

import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.aids_malaria.R;
import com.aids_malaria.app.Constant;
import com.aids_malaria.base.BaseActivity;
import com.aids_malaria.db.DBManager;
import com.aids_malaria.http.BaseObserver;
import com.aids_malaria.http.RetrofitFactory;
import com.aids_malaria.http.RxScheduler;
import com.aids_malaria.http.api.RetrofitApi;
import com.aids_malaria.http.request.DataCollectRequest;
import com.aids_malaria.http.request.DataCollectType;
import com.aids_malaria.http.response.AreaV;
import com.aids_malaria.http.response.DiagnosisInfo;
import com.aids_malaria.http.response.DiagnosisInfoPack;
import com.aids_malaria.http.response.DrugallergyInfo;
import com.aids_malaria.http.response.DrugallergyInfoPack;
import com.aids_malaria.http.response.EaProcess;
import com.aids_malaria.http.response.EaProcessPack;
import com.aids_malaria.http.response.GetMedicalTreatment;
import com.aids_malaria.http.response.GetMedicalTreatmentPack;
import com.aids_malaria.http.response.MosquitoInvest;
import com.aids_malaria.http.response.PersonData;
import com.aids_malaria.http.response.PremedicalTreatment;
import com.aids_malaria.http.response.PremedicalTreatmentPack;
import com.aids_malaria.util.AppUtil;
import com.aids_malaria.util.AuthUtil;
import com.aids_malaria.util.GsonUtil;
import com.aids_malaria.util.LogUtil;
import com.aids_malaria.util.ResourceUtil;
import com.aids_malaria.util.SpUtil;
import com.aids_malaria.util.ToastUtil;
import com.aids_malaria.widget.dialog.LoadingDialog;
import com.aids_malaria.widget.titlebar.TitleBar;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;
import okhttp3.MediaType;
import okhttp3.RequestBody;

/**
 * 上传保存数据说明：
 * 当pad完成数据采集工作后回到基地，在网络连通情况下，点击数据上传，将pad业务所采集的业务数据上传到服务器：
 * 上传保存的业务数据包括：
 * 行政区域村数据、蚊媒调查数据、人口基础数据、诊断信息数据、疫源处理数据、药物治疗数据、既往病史和治疗情况数据、药物安全性数据。
 * 数据上传之前先获取本地pad需要上传的数据数量(即新增和修改的数据，状态处于保存本地未上传)，再依次上传各数据，按已上传的条数与总数对比展现上传进度，每上传一条数据，更新本地数据记录的状态。
 * 1.  依次调用服务接口com_savePerson.do?busy_type=x(data 放在RequestBody中)，上传保存人员基础数据
 * 2.  依次调用服务接口com_saveDiagnosis_treatment.do?busy_type=xxxxxx(data 放在RequestBody中)，上传保存每个人的诊断信息数据、疫源处理数据、药物治疗数据、既往病史和治疗情况数据、药物安全性数据
 * 3.  依次调用服务接口com_saveVillage.do?busy_type=xxxxxx&data=xxxxxx?保存上传行政区域村数据
 * 4.  依次调用服务接口saveMosquito_invest.do?busy_type=xxxxxx?(data 放在RequestBody中)保存上传蚊媒调查数据
 */
public class DataUploadSettingActivity extends BaseActivity {

    @BindView(R.id.title_bar)
    TitleBar title_bar;

    @BindView(R.id.pb_personnel_collection_data)
    ProgressBar pb_personnel_collection_data;
    @BindView(R.id.personnel_collection_data_not_upload_count)
    TextView personnel_collection_data_not_upload_count;
    @BindView(R.id.personnel_collection_data_upload_count)
    TextView personnel_collection_data_upload_count;

    @BindView(R.id.pb_administrative_village_related_data)
    ProgressBar pb_administrative_village_related_data;
    @BindView(R.id.administrative_village_related_data_not_upload_count)
    TextView administrative_village_related_data_not_upload_count;
    @BindView(R.id.administrative_village_related_data_upload_count)
    TextView administrative_village_related_data_upload_count;

    @BindView(R.id.tv_all_upload)
    TextView tv_all_upload;
    @BindView(R.id.tv_personnel_collection_data_upload)
    TextView tv_personnel_collection_data_upload;
    @BindView(R.id.tv_administrative_village_related_data_upload)
    TextView tv_administrative_village_related_data_upload;

    private int personnelCollectionDataCount;
    private int administrativeVillageRelatedDataCount;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_data_upload_setting;
    }

    @Override
    protected void initView() {
        super.initView();
        initTitleBar(title_bar, ResourceUtil.getString(R.string.setting_data_upload));
    }

    @Override
    protected void initData() {
        super.initData();
        personnelCollectionDataCount = getUnUploadPersonCount() + SpUtil.getInt(mContext, Constant.UPLOAD_PERSON_DATA_COUNT,0) +
                DBManager.get().diagnosisInfoPackDao().getAllByCreateUpdate(true).size() +
                DBManager.get().eaProcessPackDao().getAllByCreateUpdate(true).size() +
                DBManager.get().getMedicalTreatmentPackDao().getAllByCreateUpdate(true).size() +
                DBManager.get().drugallergyInfoPackDao().getAllByCreateUpdate(true).size() +
                DBManager.get().premedicalTreatmentPackDao().getAllByCreateUpdate(true).size();
        pb_personnel_collection_data.setMax(personnelCollectionDataCount);
        if(personnelCollectionDataCount == 0){
            //没有数据不可上传
            tv_personnel_collection_data_upload.setClickable(false);
        }

        administrativeVillageRelatedDataCount = getUnUploadVillageCount() + getUnUploadMosCount() + SpUtil.getInt(mContext, Constant.UPLOAD_ADMINISTRATIVE_VILLAGE_COUNT,0);
        pb_administrative_village_related_data.setMax(administrativeVillageRelatedDataCount);
        if(administrativeVillageRelatedDataCount == 0){
            //没有数据不可上传
            tv_administrative_village_related_data_upload.setClickable(false);
        }

        if(personnelCollectionDataCount == 0 && administrativeVillageRelatedDataCount == 0){
            //没有数据不可上传
            tv_all_upload.setClickable(false);
        }
        updateProgress();
    }

    @OnClick({R.id.tv_all_upload,R.id.tv_personnel_collection_data_upload,R.id.tv_administrative_village_related_data_upload})
    public void onClick(View view){
        switch (view.getId()){
            case R.id.tv_all_upload:
                //上传全部
                if (!AuthUtil.isHaveUploadAuthByCode(Constant.UP_DOWN_LOAD_PERSON_DATA)
                        && !AuthUtil.isHaveUploadAuthByCode(Constant.UP_DOWN_LOAD_VILLAGE_DATA)){
                    ToastUtil.showNoPermission();
                    return;
                }
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        if (AuthUtil.isHaveUploadAuthByCode(Constant.UP_DOWN_LOAD_PERSON_DATA)){
                            savePersonData();
                            saveDiagnosisTreatment();
                        }
                        if (AuthUtil.isHaveUploadAuthByCode(Constant.UP_DOWN_LOAD_VILLAGE_DATA)){
                            saveVillage();
                            saveMosquitoInvest();
                        }
                    }
                }).start();
                break;
            case R.id.tv_personnel_collection_data_upload:
                //上传人员数据
                if (!AuthUtil.isHaveUploadAuthByCode(Constant.UP_DOWN_LOAD_PERSON_DATA)){
                    ToastUtil.showNoPermission();
                    return;
                }
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        savePersonData();
                        saveDiagnosisTreatment();
                    }
                }).start();
                break;
            case R.id.tv_administrative_village_related_data_upload:
                //上传行政村数据
                if (!AuthUtil.isHaveUploadAuthByCode(Constant.UP_DOWN_LOAD_VILLAGE_DATA)){
                    ToastUtil.showNoPermission();
                    return;
                }
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        saveVillage();
                        saveMosquitoInvest();
                    }
                }).start();
                break;
        }
    }

    /**
     * step 1
     */
    private void savePersonData(){
        List<PersonData> personDataLis = DBManager.get().personDataDao().getAllByCreateUpdate(true);
        for (PersonData personData: personDataLis){
            if (!personData.isCreateOrUpdate()){continue;}
            int busy_type = personData.getBusy_type();
            String json = GsonUtil.beanToJson(personData);
            LogUtil.d("personData:"+json);
            RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), json);
            RetrofitFactory.getInstance().createApi(RetrofitApi.class).savePersonData(busy_type, requestBody)
                    .compose(RxScheduler.rxSchedulerTransform())
                    .subscribe(new BaseObserver<Object>() {

                        @Override
                        protected void onStart() {
                            AppUtil.runOnUIThread(new Runnable() {
                                @Override
                                public void run() {
                                    LoadingDialog loadingDialog = getLoadingDialog();
                                    loadingDialog.setCancelable(false);
                                    loadingDialog.show();
                                }
                            });
                        }

                        @Override
                        protected void onSuccess(Object data) throws Exception {
                            //上传成功，删除本地
                            personData.setCreateOrUpdate(false);
                            DBManager.get().personDataDao().update(personData);
                        }

                        @Override
                        protected void onFinish() {
                            int count = SpUtil.getInt(mContext, Constant.UPLOAD_PERSON_DATA_COUNT,0);
                            ++count;
                            SpUtil.putInt(mContext, Constant.UPLOAD_PERSON_DATA_COUNT,count);
                            updateProgress();
                            AppUtil.runOnUIThread(new Runnable() {
                                @Override
                                public void run() {
                                    getLoadingDialog().dismiss();
                                }
                            });
                        }
                    });
        }
    }

    /**
     * step 2
     */
    private void saveDiagnosisTreatment(){
        List<DiagnosisInfoPack> diagnosisInfoPackList = DBManager.get().diagnosisInfoPackDao().getAllByCreateUpdate(true);
        for (DiagnosisInfoPack diagnosisInfoPack:diagnosisInfoPackList) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    saveDiagnosisTreatment(diagnosisInfoPack,null,null,
                            null,null);
                }
            }).start();
        }

        List<EaProcessPack> eaProcessPackList = DBManager.get().eaProcessPackDao().getAllByCreateUpdate(true);
        for (EaProcessPack eaProcessPack:eaProcessPackList) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    saveDiagnosisTreatment(null,eaProcessPack,null,
                            null,null);
                }
            }).start();
        }

        List<GetMedicalTreatmentPack> getMedicalTreatmentPackList = DBManager.get().getMedicalTreatmentPackDao().getAllByCreateUpdate(true);
        for (GetMedicalTreatmentPack getMedicalTreatmentPack:getMedicalTreatmentPackList) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    saveDiagnosisTreatment(null,null,getMedicalTreatmentPack,
                            null,null);
                }
            }).start();
        }

        List<DrugallergyInfoPack> drugallergyInfoPackList = DBManager.get().drugallergyInfoPackDao().getAllByCreateUpdate(true);
        for (DrugallergyInfoPack drugallergyInfoPack:drugallergyInfoPackList) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    saveDiagnosisTreatment(null,null,null,
                            drugallergyInfoPack,null);
                }
            }).start();
        }

        List<PremedicalTreatmentPack> premedicalTreatmentPackList = DBManager.get().premedicalTreatmentPackDao().getAllByCreateUpdate(true);
        for (PremedicalTreatmentPack premedicalTreatmentPack:premedicalTreatmentPackList) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    saveDiagnosisTreatment(null,null,null,
                            null,premedicalTreatmentPack);
                }
            }).start();
        }
    }

    /**
     * step 2-1
     * 分批上传，因为每种调查的busy_type都不一样
     */
    private void saveDiagnosisTreatment(DiagnosisInfoPack diagnosisInfoPack,EaProcessPack eaProcessPack,
                                        GetMedicalTreatmentPack getMedicalTreatmentPack,DrugallergyInfoPack drugallergyInfoPack,
                                        PremedicalTreatmentPack premedicalTreatmentPack){
        DataCollectType dataCollectType = new DataCollectType();

        List<DiagnosisInfo> diagnosisInfoList = new ArrayList<>();
        if(null != diagnosisInfoPack){
            diagnosisInfoList.add(DiagnosisInfo.copyFromPack(diagnosisInfoPack));
            dataCollectType.setDiagnosis_infos(diagnosisInfoPack.getBusy_type() == 1?1:2);
        }
        List<EaProcess> eaProcessList = new ArrayList<>();
        if(null != eaProcessPack){
            eaProcessList.add(EaProcess.copyFromPack(eaProcessPack));
            dataCollectType.setEa_processs(eaProcessPack.getBusy_type() == 1?1:2);
        }

        List<GetMedicalTreatment> getMedicalTreatmentList = new ArrayList<>();
        if(null != getMedicalTreatmentPack){
            getMedicalTreatmentList.add(GetMedicalTreatment.copyFromPack(getMedicalTreatmentPack));
            dataCollectType.setMeical_treatments(getMedicalTreatmentPack.getBusy_type() == 1?1:2);
        }

        List<DrugallergyInfo> drugallergyInfoList = new ArrayList<>();
        if(null != drugallergyInfoPack){
            drugallergyInfoList.add(DrugallergyInfo.copyFromPack(drugallergyInfoPack));
            dataCollectType.setDrugallergy_infos(drugallergyInfoPack.getBusy_type() == 1?1:2);
        }

        List<PremedicalTreatment> premedicalTreatmentList = new ArrayList<>();
        if(null != premedicalTreatmentPack){
            premedicalTreatmentList.add(PremedicalTreatment.copyFromPack(premedicalTreatmentPack));
            dataCollectType.setPremedical_treatments(premedicalTreatmentPack.getBusy_type() == 1?1:2);
        }

        DataCollectRequest dataCollectRequest = new DataCollectRequest();
        dataCollectRequest.setDiagnosis_infos(diagnosisInfoList);
        dataCollectRequest.setEa_processs(eaProcessList);
        dataCollectRequest.setMeical_treatments(getMedicalTreatmentList);
        dataCollectRequest.setDrugallergy_infos(drugallergyInfoList);
        dataCollectRequest.setPremedical_treatments(premedicalTreatmentList);

        LogUtil.d("dataCollectType:"+GsonUtil.beanToJson(dataCollectType));
        LogUtil.d("dataCollectRequest:"+GsonUtil.beanToJson(dataCollectRequest));

        String json = GsonUtil.beanToJson(dataCollectRequest);
        RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), json);
        RetrofitFactory.getInstance().createApi(RetrofitApi.class).saveDiagnosisTreatment(GsonUtil.beanToJson(dataCollectType),requestBody)
                .compose(RxScheduler.rxSchedulerTransform())
                .subscribe(new BaseObserver<Object>() {

                    @Override
                    protected void onStart() {
                        AppUtil.runOnUIThread(new Runnable() {
                            @Override
                            public void run() {
                                LoadingDialog loadingDialog = getLoadingDialog();
                                loadingDialog.setCancelable(false);
                                loadingDialog.show();
                            }
                        });
                    }

                    @Override
                    protected void onSuccess(Object data) throws Exception {
                        if(null != diagnosisInfoPack){
                            DBManager.get().diagnosisInfoPackDao().delete(diagnosisInfoPack);
                        }
                        if(null != eaProcessPack){
                            DBManager.get().eaProcessPackDao().delete(eaProcessPack);
                        }
                        if(null != getMedicalTreatmentPack){
                            DBManager.get().getMedicalTreatmentPackDao().delete(getMedicalTreatmentPack);
                        }
                        if(null != drugallergyInfoPack){
                            DBManager.get().drugallergyInfoPackDao().delete(drugallergyInfoPack);
                        }
                        if(null != premedicalTreatmentPack){
                            DBManager.get().premedicalTreatmentPackDao().delete(premedicalTreatmentPack);
                        }
                    }

                    @Override
                    protected void onFinish() {
                        updateProgress();
                        AppUtil.runOnUIThread(new Runnable() {
                            @Override
                            public void run() {
                                getLoadingDialog().dismiss();
                            }
                        });
                    }
                });
    }

    /**
     * step 3
     */
    private void saveVillage() {
//        List<AreaV> areaVList = LiteOrmUtil.getLiteOrm().query(AreaV.class);
        List<AreaV> areaVList = DBManager.get().areaVDao().getAllByCreateUpdate(true);
        for (AreaV areaV: areaVList){
            if (!areaV.isCreateOrUpdate()){continue;}
            String busy_type = "2".equals(areaV.getBusyType())?"2":"1";
            String dataJson = GsonUtil.beanToJson(areaV);
            LogUtil.d("dataJson:"+dataJson);
            RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), dataJson);
            RetrofitFactory.getInstance().createApi(RetrofitApi.class).saveVillage(busy_type, requestBody)
                    .compose(RxScheduler.rxSchedulerTransform())
                    .subscribe(new BaseObserver<Object>() {

                        @Override
                        protected void onStart() {
                            AppUtil.runOnUIThread(new Runnable() {
                                @Override
                                public void run() {
                                    LoadingDialog loadingDialog = getLoadingDialog();
                                    loadingDialog.setCancelable(false);
                                    loadingDialog.show();
                                }
                            });
                        }

                        @Override
                        protected void onSuccess(Object data) throws Exception {
                            //提交后删除本地数据
                            areaV.setCreateOrUpdate(false);
                            DBManager.get().areaVDao().update(areaV);
                        }

                        @Override
                        protected void onFinish() {
                            int count = SpUtil.getInt(mContext, Constant.UPLOAD_ADMINISTRATIVE_VILLAGE_COUNT,0);
                            ++count;
                            SpUtil.putInt(mContext, Constant.UPLOAD_ADMINISTRATIVE_VILLAGE_COUNT,count);
                            updateProgress();
                            AppUtil.runOnUIThread(new Runnable() {
                                @Override
                                public void run() {
                                    getLoadingDialog().dismiss();
                                }
                            });
                        }
                    });
        }
    }

    /**
     * step 4 蚊媒
     */
    private void saveMosquitoInvest() {
//        List<MosquitoInvest> mosquitoInvestList = LiteOrmUtil.getLiteOrm().query(MosquitoInvest.class);
        List<MosquitoInvest> mosquitoInvestList = DBManager.get().mosquitoInvestDao().getAllByCreateUpdate(true);
        if(mosquitoInvestList == null || mosquitoInvestList.size() == 0){
            return;
        }
        for(int i=0; i<mosquitoInvestList.size(); i++){
            MosquitoInvest mosquitoInvest = mosquitoInvestList.get(i);
            String busy_type = "1".equals(mosquitoInvest.getBusy_type())?"1":"2";
            String dataJson = GsonUtil.beanToJson(mosquitoInvest);
            LogUtil.d("dataJson:"+dataJson);
            //旧数据不上传
            if (!mosquitoInvest.isCreateOrUpdate()){continue;}
            RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), dataJson);
            RetrofitFactory.getInstance().createApi(RetrofitApi.class).saveMosquitoInvest(busy_type, requestBody)
                    .compose(RxScheduler.rxSchedulerTransform())
                    .subscribe(new BaseObserver<Object>() {

                        @Override
                        protected void onStart() {
                            AppUtil.runOnUIThread(new Runnable() {
                                @Override
                                public void run() {
                                    LoadingDialog loadingDialog = getLoadingDialog();
                                    loadingDialog.setCancelable(false);
                                    loadingDialog.show();
                                }
                            });
                        }

                        @Override
                        protected void onSuccess(Object data) throws Exception {
                            //更新本地数据
                            mosquitoInvest.setCreateOrUpdate(false);
                            DBManager.get().mosquitoInvestDao().update(mosquitoInvest);
                        }

                        @Override
                        protected void onFinish() {
                            int count = SpUtil.getInt(mContext, Constant.UPLOAD_ADMINISTRATIVE_VILLAGE_COUNT,0);
                            ++count;
                            SpUtil.putInt(mContext, Constant.UPLOAD_ADMINISTRATIVE_VILLAGE_COUNT,count);
                            updateProgress();
                            AppUtil.runOnUIThread(new Runnable() {
                                @Override
                                public void run() {
                                    getLoadingDialog().dismiss();
                                }
                            });
                        }
                    });
        }
    }

    /**
     * 更新进度
     */
    private void updateProgress(){
//        int personnelCollectionDataLeftCount = LiteOrmUtil.queryAll(PersonData.class).size() +
//                LiteOrmUtil.queryAll(DiagnosisInfoPack.class).size() +
//                LiteOrmUtil.queryAll(EaProcessPack.class).size() +
//                LiteOrmUtil.queryAll(GetMedicalTreatmentPack.class).size() +
//                LiteOrmUtil.queryAll(DrugallergyInfoPack.class).size() +
//                LiteOrmUtil.queryAll(PremedicalTreatmentPack.class).size();
        //存储以上传数量

        int personnelCollectionDataLeftCount = getUnUploadPersonCount() +
                DBManager.get().diagnosisInfoPackDao().getAllByCreateUpdate(true).size() +
                DBManager.get().eaProcessPackDao().getAllByCreateUpdate(true).size() +
                DBManager.get().getMedicalTreatmentPackDao().getAllByCreateUpdate(true).size() +
                DBManager.get().drugallergyInfoPackDao().getAllByCreateUpdate(true).size() +
                DBManager.get().premedicalTreatmentPackDao().getAllByCreateUpdate(true).size();
        pb_personnel_collection_data.setProgress(personnelCollectionDataCount-personnelCollectionDataLeftCount);
        personnel_collection_data_upload_count.setText("" + (personnelCollectionDataCount-personnelCollectionDataLeftCount));
        personnel_collection_data_not_upload_count.setText("" + personnelCollectionDataLeftCount);


//        int administrativeVillageRelatedDataLeftCount = LiteOrmUtil.queryAll(AreaV.class).size() + LiteOrmUtil.queryAll(MosquitoInvest.class).size();
        int administrativeVillageRelatedDataLeftCount = getUnUploadVillageCount() + getUnUploadMosCount();
        pb_administrative_village_related_data.setProgress(administrativeVillageRelatedDataCount-administrativeVillageRelatedDataLeftCount);
        administrative_village_related_data_upload_count.setText("" + (administrativeVillageRelatedDataCount-administrativeVillageRelatedDataLeftCount));
        administrative_village_related_data_not_upload_count.setText("" + administrativeVillageRelatedDataLeftCount);
    }

    //获取未上传基础人员数
    private int getUnUploadPersonCount(){
        List<PersonData> personDataList = DBManager.get().personDataDao().getAllByCreateUpdate(true);
        int totalUploadIPerson = 0;
        ArrayList temp = new ArrayList();
        for (int i = 0; i < personDataList.size(); i++) {
            if (personDataList.get(i).isCreateOrUpdate()){
                totalUploadIPerson++;
                temp.add(personDataList.get(i));
            }
        }
        LogUtil.d("基础人员未" + GsonUtil.beanToJson(temp));
        return totalUploadIPerson;
    }

    //获取未上传蚊媒数
    private int getUnUploadMosCount(){
        List<MosquitoInvest> mosList = DBManager.get().mosquitoInvestDao().getAllByCreateUpdate(true);
        int totalUploadInvest = 0;
        ArrayList temp = new ArrayList();
        for (int i = 0; i < mosList.size(); i++) {
            if (mosList.get(i).isCreateOrUpdate()){
                totalUploadInvest++;
                temp.add(mosList.get(i));
            }
        }
        LogUtil.d("蚊媒未" + GsonUtil.beanToJson(temp));
        return totalUploadInvest;
    }

    //获取未上传行政村数
    private int getUnUploadVillageCount(){
        int totalAreaV = 0;
        ArrayList temp2 = new ArrayList();
        List<AreaV> arealist = DBManager.get().areaVDao().getAllByCreateUpdate(true);
        for (int i = 0; i < arealist.size(); i++) {
            if (arealist.get(i).isCreateOrUpdate()){
                totalAreaV++;
                temp2.add(arealist.get(i));
            }
        }
        LogUtil.d("行政村未" + GsonUtil.beanToJson(temp2));
        return totalAreaV;
    }



}
